function navigate(url,fn='navigateTo') {
 	uni[fn]({
 		url: url
 	});
 }

 function back(n = 1) {
 	uni.navigateBack({
 		delta: n
 	})
 }

function putData(data,userId){
	console.log(data,userId)
	
	let $data = {};//上传的数据
	$data['user_id']=userId;
	$data['shop_id']=data.shop_id;
	$data['sign_in']={
    "sign_time": "2020-03-03 16:57:15",
    "longitude": 113.369076,
    "latitude": 113.310259,
    "imgs": ["img1.jpg", "img2.jpg"]
  };
	$data['quesiont']={};
	$data['quesiont']['1']=[];
	$data['quesiont']['2']=[];
	$data['quesiont']['3']=[];
	$data['quesiont']['4']=[];
	$data['quesiont']['5']=[];
	$data['quesiont']['6']=[];
	$data['quesiont']['7']=[];
	//第一部分
	  //问题Q1
	let $1={};
	$1['q1']=[]
	data.q1.forEach(element => {
		element.forEach(ele => {
			let obj={}
			obj['goods_id'] = ele.goods_id
			obj['value'] = ele.value
			$1['q1'].push(obj)
		});
	});
	  //问题Q2
	$1['q2']=[]
	data.q1.forEach(element => {
		element.forEach(ele => {
			if(ele.value == 1){
				let obj={}
				obj['goods_id'] = ele.goods_id
				obj['value'] = ele.num
				$1['q2'].push(obj)
			}
		});
	});
	  //问题Q3
	$1['q3']=[]
	data.q1.forEach(element => {
		element.forEach(ele => {
			if(ele.value == 2){
				let obj={}
				obj['goods_id'] = ele.goods_id
				obj['value'] = ele.q3value || ele.value
				$1['q3'].push(obj)
			}
		});
	});
	 //问题Q3-1
	$1['q3-1']=[]
	if(data.q3_1){
		data.q3_1.item.forEach(element => {
			let obj={}
			obj['id'] = element.id
			obj['value'] = element.value || 2
			$1['q3-1'].push(obj)
		});
	}
	$data['quesiont']['1'].push($1)
	//第二部分
	  //问题Q4
	let $2 ={};
	$2['q4']=[]
	data.q1.forEach(element => {
		element.forEach(ele => {
			if(ele.value == 1){
				let obj={}
				obj['goods_id'] = ele.goods_id
				obj['value'] = ele.price
				$2['q4'].push(obj)
			}
		});
	});
	$data['quesiont']['2'].push($2)
	//第三部分
	  //问题Q5
	if(data.q5){
		data.q5.forEach(element=>{
			let $3 ={};
			$3['q5']=[]
			element.categoryList.forEach(ele => {
				ele.item.forEach(e=>{
					e.item.forEach(i=>{
						let obj={}
						obj['id'] = i.id
						obj['value'] = i.value || 1
						$3['q5'].push(obj)
					})
				})
			});
			$data['quesiont']['3'].push($3)
		})
	}
	//第四部分
	  //问题Q8
	if(data.q8){
		data.q8.forEach(element=>{
			let $4 ={};
      $4['q8'] = element[0].id[element[0].index];
			$4['q9'] = element[1].id[element[1].index1];
			$4['q10'] = element[2].id[element[2].index2];
			$4['q11'] = element[3].text;
			$4['q12'] = element[4].text;
			$data['quesiont']['4'].push($4)
		})
  }
  //第五部分
    //问题Q16
  if(data.sel){
    let length = data.sel[13].sel_data.length;
    for(let i=0;i<length;i++){
      let $5 = {};
      //$5['16'] = data.sel[13].sel_data[i].value;
      $5['q17'] = data.sel[14].sel_data[i].value;
      $5['q18'] = data.sel[15].sel_data[i].value;
      $5['q19'] = []
      data.sel[16].sel_data[i].item.forEach((element,index)=>{
        let obj = {}
        obj['id'] = index+1;
        obj['value'] = element.value || 2;
        $5['q19'].push(obj)
      })
      $data['quesiont']['5'].push($5)
    }
  }

  //第六部分
    //问题Q21
  if(data.sel){
    let length = data.sel[18].sel_data.length;
    for(let i=0;i<length;i++){
      let $6 = {};
      $6['q22'] = data.sel[19].sel_data[i].item[0];
      $6['q23'] = data.sel[20].sel_data[i].item[data.sel[20].sel_data[i].value-1].id;
      $6['q24'] = data.sel[21].sel_data[i].item[data.sel[21].sel_data[i].value-1].id;
      $6['q26'] = []
      data.sel[23].sel_data[i].forEach((element,index)=>{
        let obj = {}
        let getindex,getindex1
        element.cs.forEach((ele,ind)=>{
          if(ele == element.val){
            getindex = ind
            return;
          }
        })
        element.fl.forEach((ele,ind)=>{
          if(ele == element.val1){
            getindex1 = ind
            return;
          }
        })
        obj['cs_id'] = element.csid[getindex] ==undefined?"":element.csid[getindex]
        obj['fl_id'] = element.flid[getindex1] ==undefined?"":element.flid[getindex1]
        obj['value'] = element.value
        obj['item'] = {}
        $6['q26'].push(obj)
      })
      $data['quesiont']['6'].push($6)
    }
  }
  //第七部分
    //问题Q27
  if(data.sel){
    let length = data.sel[26].sel_data.length;
    for(let i=0;i<length;i++){
      let $7 = {};
      $7['q27'] = []
      data.sel[26].sel_data[i].forEach((element,index)=>{
        if(element.value == 1){
          $7['q27'].push(element.id)
        }
      })
      $data['quesiont']['7'].push($7)
    }
  }
  console.log($data)
  return $data
}

 module.exports = {
	 navigate: navigate,
	 putData:putData
 }
var a = {
  "user_id": 144,
  "shop_id": 1001,
  "quesiont": {
    "1": [{
      "q1": [{
          "goods_id": 1,
          "value": 1
        },
        {
          "goods_id": 2,
          "value": 1
        },
        {
          "goods_id": 3,
          "value": 2
        },
        {
          "goods_id": 4,
          "value": 2
       }],
      "q2": [{
        "goods_id": 1,
        "value": 10
      }, {
        "goods_id": 2,
        "value": 5
      }],
      "q3": {
        "0": {
          "goods_id": 1,
          "value": 1
        },
        "1": {
          "goods_id": 2,
          "value": 1
        },
        "2": {
          "goods_id": 3,
          "value": 1
        },
        "4": {
          "goods_id": 4,
          "value": 2
        }
      },
      "q3_1": [{
        "id": 1,
        "value": 1
      }, {
        "id": 2,
        "value": 2
      }]
    }],
    "2": [{
      "q4": {
        "0": {
          "goods_id": 1,
          "value": 2.5
        },
        "1": {
          "goods_id": 2,
          "value": 2.5
        },
        "2": {
          "goods_id": 3,
          "value": 3.5
        },
        "4": {
          "goods_id": 4,
          "value": 6.5
        }
      }
    }],
    "3": [{
      "q5": {
        "0": {
          "id": 34,
          "value": 2
        },
        "1": {
          "id": 35,
          "value": 2
        },
        "2": {
          "id": 38,
          "value": 2
        },
        "4": {
          "id": 39,
          "value": 2
        }
      }
    }, {
      "q5": {
        "0": {
          "id": 34,
          "value": 2
        },
        "1": {
          "id": 35,
          "value": 2
        },
        "2": {
          "id": 38,
          "value": 2
        },
        "4": {
          "id": 39,
          "value": 2
        }
      }
    }],
    "4": [{
      "q8": 1,
      "q9": 1,
      "q10": {
        "id": 7,
        "value": "\u5176\u4ed6\u5730\u65b9"
      },
      "q11": 3,
      "q12": {
        "id": 13,
        "value": "\u5176\u4ed6\u5730\u65b9"
      }
    }, {
      "q8": 1,
      "q9": 1,
      "q10": {
        "id": 7,
        "value": "\u5176\u4ed6\u5730\u65b9"
      },
      "q11": 3,
      "q12": {
        "id": 13,
        "value": "\u5176\u4ed6\u5730\u65b9"
      }
    }],
    "5": [{
      "q17": 2,
      "q18": 4,
      "q19": [{
        "id": 1,
        "value": 2
      }, {
        "id": 2,
        "value": 2
      }, {
        "id": 3,
        "value": 2
      }]
    }, {
      "q17": 2,
      "q18": 4,
      "q19": [{
        "id": 1,
        "value": 2
      }, {
        "id": 2,
        "value": 2
      }, {
        "id": 3,
        "value": 2
      }]
    }],
    "6": [{
      "q22": "uploads\/goods\/1578619730388492657.jpg",
      "q23": 1,
      "q24": {
        "id": 1,
        "value": "\u8fd9\u91cc\u662f\u5176\u4ed6\u8f93\u5165\u503c"
      },
      "q26": [{
        "cs_id": 1,
        "fl_id": 1,
        "value": 9,
        "item": {
          "1": 2,
          "2": 3,
          "3": 4
        }
      }, {
        "cs_id": 2,
        "fl_id": 2,
        "value": 8,
        "item": {
          "1": 2,
          "2": 3,
          "3": 3
        }
      }, {
        "cs_id": 3,
        "fl_id": 3,
        "value": 7,
        "item": {}
      }]
    }, {
      "q22": "uploads\/goods\/1578619730388492657.jpg",
      "q23": 1,
      "q24": {
        "id": 1,
        "value": "\u8fd9\u91cc\u662f\u5176\u4ed6\u8f93\u5165\u503c"
      },
      "q26": [{
        "cs_id": 1,
        "fl_id": 1,
        "value": 9,
        "item": {
          "1": 2,
          "2": 3,
          "3": 4
        }
      }, {
        "cs_id": 2,
        "fl_id": 2,
        "value": 8,
        "item": {
          "1": 2,
          "2": 3,
          "3": 3
        }
      }, {
        "cs_id": 3,
        "fl_id": 3,
        "value": 7,
        "item": []
      }]
    }],
    "7": [{
      "q27": [1, 2, 3]
    }]
  },
  "sign_in": {
    "sign_time": "2020-01-01 14:57:15",
    "longitude": 113.369076,
    "latitude": 113.310259,
    "imgs": ["img1.jpg", "img2.jpg"]
  }
}